cmake_minimum_required(VERSION 3.16)

project(infoqtlib LANGUAGES CXX)

set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Core)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core)

FILE(GLOB ORIGIN *.h *.cpp)
FILE(GLOB INCLUDEPUBLIC include/*.h include/*.cpp)

source_group(include FILES ${INCLUDEPUBLIC})

set(PROJECT_SOURCES
    ${ORIGIN}
    ${INCLUDEPUBLIC}
)


if (INFPQTLIB_BUILD_STATIC_LIB)
    set(LIB_TYPE "STATIC")
else ()
    set(LIB_TYPE "SHARED")
endif ()

add_library(${PROJECT_NAME} ${LIB_TYPE}
    ${PROJECT_SOURCES}
)
target_include_directories(${PROJECT_NAME} PRIVATE include )

target_link_libraries(${PROJECT_NAME} PRIVATE Qt${QT_VERSION_MAJOR}::Core)

target_compile_definitions(${PROJECT_NAME} PRIVATE INFOQTLIB_LIBRARY)
